home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1996 December / PC Answers December 1996.iso / create / corelcad / cad / ftpsend.csc < prev    next >
Encoding:
Text File  |  1996-05-06  |  15.7 KB  |  419 lines

  1. 'This script exports an STL file to a service bureau
  2. 'STL FTP SEND Script -- 
  3. 'This script exports any Solid selected to a Stereolithography (STL) file and sends it, 
  4. 'along with some user information, via FTP to any one of 5 STL Service Bureaus. The goal is to 
  5. 'facilitate and expedite the file transfer between customers and STL sites for estimates or orders.  
  6. '
  7. '************************************************************************************************
  8. '***********************************  STL FTP SEND Script ***************************************
  9. '************************************************************************************************
  10. '
  11. 'April 22, 1996    
  12. '
  13. '    This script exports a Stereolithography(STL) file for any Solids created in CorelCAD.
  14. '  The STL file is then transmitted via FTP to the Service Bureau Selected. We assume that you
  15. '  have TC\PIP protocol installed and that you are connected to an internet provider that supports 
  16. '  the TC\PIP protocol.
  17. '
  18. '  The user defines:
  19. '                - File name of Exported file(*.STL) to be created
  20. '                - User Information: Name, company name, address, phone, fax, E-mail
  21. '                - One Service Bureau.
  22. '                - Additional comments or instructions
  23. '************************************************************************************************
  24. '************************************************************************************************
  25. '************************************************************************************************
  26. '************************************************************************************************
  27. ' Additional Comments:
  28. '
  29. '                - First Create and save your solid model.
  30. '                - Run the STLScript.csc from Tools menu\Script\run script
  31. '                - Enter your info in the Left half of the "FTP delivery to STL Service Bureau"
  32. '                  Dialog
  33. '                - In the right half of the "FTP delivery to STL Service Bureau" dialog enter:
  34. '                  Your Name, Your company name, Your address, Your phone, Your fax, Your E-mail.
  35. '                - The file name to be exported (NOTE: to prevent unexpected results keep the 
  36. '                  file name down to seven letters.)
  37. '                - Select the Service Bureau by clicking on the "change button"
  38. '                - From the "STL Service Bureau" dialog select the Service Bureau of your choice
  39. '                  (NOTE: To update the Service Bureau information click on the "update" button
  40. '                - Each Service Bureau has a phone number and a contact name in case you need to 
  41. '                  setup an individual account.
  42. '                - Once you have selected the Service Bureau of your choice click "ok" to return.
  43. '                  If you are sending information to a Service Bureau which is not listed then simply
  44. '                  add the FTP address information manually.
  45. '                - Add comments or instructions to Service Bureau in the Comments section at the 
  46. '                  bottom right of the "FTP delivery to STL Service Bureau" dialog.
  47. '                 - Update to refresh the information. 
  48. '                - Click on Send and sit back and enjoy the scenery. (It may take a long time with some 
  49. '                  of the bigger files. High refinement settings will slow down the export of your file, 
  50. '                   but will give you a more accurate solid.)
  51. '                
  52. '                  
  53. '************************************************************************************************
  54. '************************************************************************************************
  55. 'Written by Jean-Louis Marin and David Climie,   ⌐ 1995-96 Corel Corporation. All rights reserved.
  56. '************************************************************************************************
  57. '************************************************************************************************
  58. '************************        DECLARATIONS       *********************************************
  59. '************************************************************************************************
  60. '************************************************************************************************
  61. DECLARE FUNCTION WinExec LIB "kernel32" (BYVAL path AS STRING, BYVAL shw AS LONG) AS LONG ALIAS "WinExec"
  62. DECLARE SUB DOSEND()
  63. DECLARE SUB DODSYS()
  64. DECLARE SUB FIN()
  65. DECLARE SUB DOUPDATE()
  66. DECLARE SUB MakeFTPFile()
  67. DECLARE SUB MakeUserFile()
  68. DECLARE SUB ExportSTLFile()
  69. REM DECLARE FUNCTION CountFTPFiles%(FName$)
  70.  
  71. Global Comp%
  72.  
  73.     Comp = 1
  74.  
  75. Global Company$(5)
  76.  
  77.     Company$(1) = "Alta Precision"
  78.     Company$(2) = "Advantage Engineering"
  79.     Company$(3) = "Concept Plus"
  80.     Company$(4) = "EDI"
  81.     Company$(5) = "Factotum"
  82.     
  83. Global Complex$(5,4)
  84.     
  85.     Complex$(1,1)= "204.101.187.2"
  86.     Complex$(1,2)= "alta"
  87.     Complex$(1,3)= "alta11120"
  88.     Complex$(1,4)= "\alta"
  89.     Complex$(2,1)= ""
  90.     Complex$(2,2)= ""
  91.     Complex$(2,3)= ""
  92.     Complex$(2,4)= ""
  93.     Complex$(3,1)= "139.13.16.161"
  94.     Complex$(3,2)= "concept"
  95.     Complex$(3,3)= "concept"
  96.     Complex$(3,4)= "\Incoming"
  97.     Complex$(4,1)= ""
  98.     Complex$(4,2)= ""
  99.     Complex$(4,3)= ""
  100.     Complex$(4,4)= ""
  101.     Complex$(5,1)= "shell.inforamp.net"
  102.     Complex$(5,2)= "Factotum"
  103.     Complex$(5,3)= "sla250"
  104.     Complex$(5,4)= ""
  105.  
  106. GLOBAL FileName$
  107. GLOBAL FileNamee$
  108. GLOBAL Con$
  109. GLOBAL Conn$
  110.  
  111. Con$ = CHR(13)+ CHR(10)
  112. Conn$ = CHR(13)
  113.  
  114.  
  115. GLOBAL UserName$                '
  116. GLOBAL CompanyName$
  117. GLOBAL Address$
  118. GLOBAL PhoneNumber$
  119. GLOBAL FaxNumber$
  120. GLOBAL Email$
  121. GLOBAL commentTxt$
  122. GLOBAL ErrorVar%                'Used to make sure user enters a correct path name
  123.  
  124.  
  125.  
  126. UserName$ = "UserName"
  127. CompanyName$ = "Company Name"
  128. Address = "Address"
  129. PhoneNumber = "(555)555-5555"
  130. FaxNumber = "(555)555-5555"
  131. Email = "EMail@Site.Ca"
  132. FileName = "Default"
  133. commentTxt = "Add comments to Service Bureau Here."
  134.  
  135.  
  136. START:    
  137.  
  138.  
  139. BEGIN DIALOG StartDia 334, 216, "FTP delivery to STL Service Bureau "
  140.     PUSHBUTTON  280, 56, 40, 14, "Change"
  141.     PUSHBUTTON  180, 190, 40, 14, "Update"
  142.     PUSHBUTTON  230, 190, 40, 14, "Send"
  143.     CANCELBUTTON  280, 190, 40, 14
  144.     TEXTBOX  14, 25, 140, 14, UserName$
  145.     TEXTBOX  14, 55, 140, 13, CompanyName$
  146.     TEXTBOX  14, 84, 140, 14, Address$
  147.     TEXTBOX  14, 115, 140, 14, PhoneNumber$
  148.     TEXTBOX  14, 145, 140, 14, FaxNumber$
  149.     TEXTBOX  14, 175, 140, 13, Email$
  150.     TEXTBOX  180, 25, 140, 14, FileName$
  151.     TEXTBOX  180, 56, 97, 14, Company(Comp)            'Company(Comp)
  152.     TEXTBOX  216, 73, 104, 13, Complex(Comp,1)         'Complex(Comp,1)
  153.     TEXTBOX  216, 89, 104, 13, Complex(Comp,2)         'Complex(Comp,2)
  154.     TEXTBOX  216, 105, 104, 13, Complex(Comp,3)         'Complex(Comp,3)
  155.     TEXTBOX  215, 120, 104, 12, Complex(Comp,4)         'Complex(Comp,4)
  156.     TEXTBOX  180, 147, 140, 27, commentTxt$
  157.     GROUPBOX  170, 180, 160, 30, ""                        ' put "" after this one
  158.     GROUPBOX  174, 3, 160, 133, "File Information:"
  159.     TEXT  180, 15, 50, 8, "File Name:"
  160.     TEXT  14, 164, 133, 8, "E-mail"
  161.     TEXT  14, 135, 133, 8, "Fax:"
  162.     TEXT  14, 105, 134, 8, "Phone"
  163.     TEXT  14, 75, 133, 8, "Address"
  164.     TEXT  14, 44, 133, 8, "Company Name:"
  165.     TEXT  14, 15, 133, 8, "User Name:"
  166.     GROUPBOX  4, 0, 160, 210, "User Information:"
  167.     TEXT  180, 44, 120, 8, "STL Service Bureau:"
  168.     GROUPBOX  170, 137, 160, 43, "Comments"
  169.     TEXT  176, 75, 26, 8, "TC/PIP:"
  170.     TEXT  176, 89, 38, 8, "User Name:"
  171.     TEXT  176, 105, 38, 8, "Password:"
  172.     TEXT  176, 123, 37, 8, "Path Name:"
  173. END DIALOG
  174.  
  175.     return = DIALOG(StartDia)        'Runs the dialog box
  176.     If return = 2 then stop             'If the user presses ESC, cancels the script
  177.  
  178.     If (UserName$ = "") or (Phonenumber$ = "") then 
  179.         BEGIN DIALOG ErrorVarDiaa 120, 90, "Error"
  180.         TEXT  15, 6, 90, 13, "INCORRECT FORMAT !!!!"
  181.         TEXT  5, 24, 110, 36, "Corel Script has detected that your Name or Phone number have not been entered. Please verify, and add them to the User Information."
  182.         OKBUTTON  10, 70, 40, 14
  183.         CANCELBUTTON  70, 70, 40, 14
  184.         END DIALOG
  185.         ret = DIALOG(ErrorVarDiaa)
  186.         Goto Start    
  187.     endif
  188.     
  189.     ErrorVar = False    
  190.     
  191.     FileName = LTRIM(FileName)
  192.     FileName = RTRIM(FileName)
  193.     FileName = UCASE(FileName)
  194.         
  195.     If (cbol(instr(FileName,":"))=true) or (cbol(instr(FileName,"\"))=true) then ErrorVar = true
  196.     If NOT((Right(FileName,4))=".STL") then FileName=FileName & ".STL"        
  197.     
  198.     PosPeriod = 0
  199.  
  200.     If (PosPeriod <>0) and UCASE(right(FileName,4)) <> ".STL" then ErrorVar = True
  201.     REM ErrorVar = FALSE            '*** TAKE OUT REM IF YOU WANT TO OVERIDE ERROR TRAP ***
  202.  
  203. If ErrorVar = true then
  204.  
  205. BEGIN DIALOG ErrorVarDia 194, 123, "Error"
  206.     TEXT  24, 0, 170, 12, "INCORRECT FORMAT !!!!"
  207.     TEXT  22, 15, 142, 33, "Corel Script has detected that your FILE NAME entry is invalid. Please verify, and change accordingly."
  208.     GROUPBOX  22, 49, 143, 43, "Examples  "
  209.     OKBUTTON  22, 100, 40, 15
  210.     CANCELBUTTON  123, 100, 40, 15
  211.     TEXT  32, 62, 52, 8, "Widget1.SLT"
  212.     TEXT  98, 62, 48, 8, "Widget"
  213.     TEXT  33, 76, 112, 8, "Rotating Coil.SLT"
  214. END DIALOG
  215.  
  216.     ret = DIALOG(ErrorVarDia)
  217.     If ret = 2 then STOP
  218.     FileName = "Default.STL"
  219.     Goto Start
  220. ENDIF
  221.  
  222.     If return = 3 then                  'Updates the variables
  223.             DODSYS
  224.             goto start
  225.         elseIf return = 4 then
  226.             DOUPDATE
  227.             goto start
  228.         elseIf return = 5 then
  229.             DOSEND
  230.             FIN
  231.     endif
  232.  
  233.     FileName = "C:\TEMP\" & FileName
  234.     message filename
  235.  
  236.  
  237.     WITHOBJECT "CorelCAD.Automation.1"
  238.         .setvisible -1
  239.         .FileExport FileName,769,1000,700, 85, 85, 4
  240.     END WITHOBJECT
  241.     
  242.  
  243.  
  244. '************************************************************************************************
  245. '************************************************************************************************
  246. '************************************************************************************************
  247.  
  248. SUB DODSYS
  249. DIM FA1$
  250. DIM FA2$
  251. DIM CompInfo$(7)
  252. FA1 = "Factotum Plastics Technology"
  253. FA2 = "Mississauga, Ontario"
  254. FA3 = "Call to get your" & con$ & "personal FTP account"
  255. CompInfo$(1) = "Alta Precision Prototypes" & con$ & "1120 Rue Colbert" & con$ & "Ville D'Anjou, Quebec" & con$ & "Canada" & con$ & "H1J 2S1" & con$ & "Phone: (514) 353-0919" & con$ & "Fax: (514) 353-3599" & con$ & "Contact: Guillermo Alonso Jr."
  256. CompInfo$(2) = "Advantage Engineering" & con$ & "2500 Central Ave." & con$ & "Windsor, Ontario" & con$ & "Canada" & con$ & "N8W 4J5" & con$ & "Phone: (519) 974-7366" & con$ & "Fax: (519) 974-8850" & con$ & "Contact: Steve Hengsperger" & con$ & FA3
  257. CompInfo$(3) = "Concept Plus" & con$ & "180 Blv St-George" & con$ & "Moncton,New Brunswick" & con$ & "Canada" & con$ & "E1E 4K7" & con$ & "Phone: (506) 858-4153" & con$ & "Fax: (506) 858-4075" & con$ & "Contact: Willam LeBlanc"
  258. CompInfo$(4) = "EDI" & con$ & "510 Front St. West" & con$ & "Toronto, Ontario" & con$ & "Canada" & con$ & "M5V 1B8" & con$ & "Phone: (416) 593-4663" & con$ & "Fax: (416) 593-4898" & con$ & "Contact: Jerry Moscovitch" & con$ & FA3
  259. CompInfo$(5) = FA1$ & con$ & "Suite 200" & con$ & "58 Abler Drv." & con$ & FA2$ & con$ & "Canada"& con$ &"L4W 4J4"& con$ &"Phone: (905) 602-7986"& con$ &"Fax: (905) 602-7993"& con$ &"Contact: Craig Ferchat"
  260.  
  261. DIM CompanyInfo$
  262.     
  263.  
  264.  
  265. DialogAgain:
  266.     CompanyInfo = CompInfo(Comp)
  267. BEGIN DIALOG Dl 170, 184, "STL Service Bureaus"
  268.     GROUPBOX  5, 4, 160, 40, "Service Bureau"
  269.     OKBUTTON  15, 163, 50, 14
  270.     CANCELBUTTON  100, 163, 50, 14
  271.     GROUPBOX  5, 47, 160, 108, "Service Bureau Information"
  272.     TEXT  15, 60, 140, 85, CompanyInfo$
  273.     PUSHBUTTON  120, 18, 40, 15, "Update"
  274.     DDLISTBOX  15, 19, 95, 132, Company$, Comp%
  275. END DIALOG
  276.    
  277.     ret = DIALOG(Dl)
  278.  
  279.     If ret = 2 then goto AllDone
  280.  
  281.     If ret = 1 then goto AllDone
  282.  
  283.     If ret = 3 then goto DialogAgain
  284.  
  285.  
  286. '    ENDIF
  287. AllDONE:
  288. END SUB
  289.  
  290. '************************************************************************************************
  291. '************************************************************************************************
  292. '************************************************************************************************
  293.  
  294. SUB FIN
  295. stop
  296. END SUB
  297.  
  298. '****************************************************************************************************************
  299. '****************************************************************************************************************
  300. '****************************************************************************************************************
  301. '****************************************************************************************************************
  302. SUB DOSEND
  303.  
  304. DIM CallThing$
  305.  
  306. FileNamee$ = LEFT(FileName$, INSTR(FileName$, ".STL")-1)
  307.  
  308. MakeFTPFile
  309. MakeUserFile
  310. ExportSTLFile
  311. CallThing = "ftp -i -s:C:\ftpfile.txt"
  312.  
  313.     err = WinExec(CallThing$, 1)
  314.     IF err < 0 THEN err = err * -1
  315.     IF err < 33 THEN
  316.         MESSAGE "Could not find C:\FTPFile.txt. Please find the file on your CorelCAD CD and place it in the appropriate directory."
  317.         STOP
  318.     ENDIF
  319.  
  320. end sub
  321.  
  322. '****************************************************************************************************************
  323. '****************************************************************************************************************
  324. SUB DOUPDATE
  325.  
  326. end sub
  327. '****************************************************************************************************************
  328. '****************************************************************************************************************
  329. SUB MAKEFTPFILE
  330.  
  331.  
  332. Dim N1$,N2$,N3$,N4$,N5$,N6$,N7$,N8$,N9$,N10$,N11$
  333.  
  334. N1= "open " + Complex(Comp,1) 
  335. N2= Complex(Comp,2) 
  336. N3= Complex(Comp,3) 
  337. N4= "cd " + Complex(comp,4)
  338. N5= "mput" + " " +"C:\" + FileNamee + "*.STL"
  339. N6= ""
  340. N7= "" rem Complex(Comp,4) + FileNamee + "*.STL" 
  341. N8= "put" 
  342. N9= "C:\" + FileNamee + ".txt" 
  343. N10= Complex(Comp,4) + "\" +FileNamee + ".txt" 
  344. N11= "bye" 
  345.  
  346.  
  347.  
  348. OPEN "C:\ftpfile.txt" FOR OUTPUT AS 1
  349.  print #1, N1 
  350.  print #1, N2
  351.  print #1, N3
  352.  print #1, N4
  353.  print #1, N5
  354.  print #1, N6
  355.  print #1, N7
  356.  print #1, N8
  357.  print #1, N9
  358.  print #1, N10
  359.  print #1, N11
  360.  
  361. CLOSE 1
  362.  
  363. END SUB
  364. '****************************************************************************************************************
  365. '****************************************************************************************************************
  366. SUB MakeUserFile
  367.  
  368. Dim U1$,U2$,U3$,U4$,U5$,U6$,U7$,U8$,U9$
  369.  
  370.  
  371. U1="CUSTOMER NAME:" + UserName$ 
  372. U2="COMPANY NAME:" + CompanyName$
  373. U3="ADDRESS:" + Address$ 
  374. U4= "Phone Number:" + PhoneNumber$
  375. U5= "Fax Number:" + FaxNumber$
  376. U6= "E-Mail Address:" + Email$
  377. U7= "STL File Name:" + FileNamee$ + "*.STL" 
  378. U8= "NOTE:Each solid will be in a seperate File."
  379. U9= "Customer Request:" + commentTxt$ 
  380.  
  381.  
  382. OPEN "C:\" + FileNamee$ + ".TXT"  FOR OUTPUT AS 2
  383.  print #2, U1
  384.  Print #2, U2
  385.  Print #2, U3
  386.  Print #2, U4
  387.  Print #2, U5
  388.  Print #2, U6
  389.  Print #2, U7
  390.  Print #2, U8
  391.  Print #2, U9
  392. CLOSE 2
  393.  
  394. end sub
  395. '****************************************************************************************************************
  396. '****************************************************************************************************************
  397. SUB ExportSTLFile
  398.     WITHOBJECT "CorelCAD.Automation.1"
  399.         .setvisible -1
  400.         .FileExport "C:\" & FileName$
  401.     END WITHOBJECT
  402.  
  403.  
  404.  
  405. end sub
  406. '****************************************************************************************************************
  407. '****************************************************************************************************************
  408. '****************************************************************************************************************
  409. '****************************************************************************************************************
  410. '****************************************************************************************************************
  411. '****************************************************************************************************************
  412. '****************************************************************************************************************
  413. '****************************************************************************************************************
  414. '****************************************************************************************************************
  415. '****************************************************************************************************************
  416.  
  417.  
  418.  
  419.